{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Time-dependent PDEs"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 1,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\n",
        "import matplotlib.pyplot as pt"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 2,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "def rk4_step(y, t, h, f):\n",
        "    k1 = f(t, y)\n",
        "    k2 = f(t+h/2, y + h/2*k1)\n",
        "    k3 = f(t+h/2, y + h/2*k2)\n",
        "    k4 = f(t+h, y + h*k3)\n",
        "    return y + h/6*(k1 + 2*k2 + 2*k3 + k4)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 11,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "mesh = np.linspace(0, 1, 200)\n",
        "dx = mesh[1]-mesh[0]"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "(all of the PDEs below use *periodic* boundary conditions: $u(0)=u(1)$)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "**Advection equation:** $u_t+u_x=0$\n",
        "\n",
        "Equivalent: $u_t=-u_x$"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 12,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "def f_advection(t, u):\n",
        "    du = (np.roll(u, -1, axis=-1) - np.roll(u, 1, axis=-1))/(2*dx)\n",
        "    return -du"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "**Heat equation:** $u_t=u_{xx}$"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 13,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "def f_heat(t, u):\n",
        "    d2u = (\n",
        "        np.roll(u, -1, axis=-1)\n",
        "        - 2*u\n",
        "        + np.roll(u, 1, axis=-1))/(dx**2)\n",
        "    return d2u"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "**Wave equation:** $u_{tt}=u_{xx}$\n",
        "\n",
        "NOTE: Two time derivatives $\\rightarrow$ convert to first order ODE.\n",
        "\n",
        "$$u_t=v$$\n",
        "$$v_t=u_{xx}$$\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 14,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "def f_wave(t, w):\n",
        "    u, v = w\n",
        "    d2u = (\n",
        "        np.roll(u, -1, axis=-1)\n",
        "        - 2*u\n",
        "        + np.roll(u, 1, axis=-1))/(dx**2)\n",
        "    return np.array([v, d2u])"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "**Initial condition**"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 15,
      "metadata": {
        "collapsed": false
      },
      "outputs": [
        {
          "data": {
            "text/plain": [
              "(1, 200)"
            ]
          },
          "execution_count": 15,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "current_t = 0\n",
        "\n",
        "#current_u = np.sin(2*np.pi*mesh)*0.5+1\n",
        "#current_u = (mesh > 0.3) & (mesh < 0.7)\n",
        "#current_u = (mesh > 0.45) & (mesh < 0.55)\n",
        "current_u = np.exp(-(mesh-0.5)**2*150)\n",
        "#current_u = 2*np.abs(mesh-0.5)\n",
        "\n",
        "current_u = np.array([current_u], dtype=np.float64)\n",
        "current_u.shape"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 16,
      "metadata": {
        "collapsed": false
      },
      "outputs": [
        {
          "data": {
            "text/plain": [
              "(2, 200)"
            ]
          },
          "execution_count": 16,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "# Add a second component if needed (for wave equation)\n",
        "current_u = np.vstack([current_u,np.zeros(len(mesh))])\n",
        "current_u.shape"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "**Time loop**"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Run this cell many times in place (using Ctrl-Enter):"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 26,
      "metadata": {
        "collapsed": false
      },
      "outputs": [
        {
          "data": {
            "text/plain": [
              "[<matplotlib.lines.Line2D at 0x7ff76cdad668>]"
            ]
          },
          "execution_count": 26,
          "metadata": {},
          "output_type": "execute_result"
        },
        {
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAD7CAYAAACMlyg3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmcVXX9x/HXR3AtYTQXFJEJwSW3AdO0CEZQwS2s3DDR\nKbcWUyoNKg1xS8USjKyfqY1LimuapoIpFzBU3MYFAU1CQcxcMM0VmM/vj+8dzjgOw8zcc+855973\n8/G4D+fMPXPOxw/33s89388532PujoiIVKa1kg5ARESSoyIgIlLBVARERCqYioCISAVTERARqWAq\nAiIiFaxr0gE0Z2Y6X1VEpBPc3Trzd6k7EnB3PdwZN25c4jGk5aFcKBfKRduPQqSuCEiwaNGipENI\nDeUiolxElIt4xFIEzOxKM3vNzJ5ezfNHmdlTZtZgZg+a2c5x7FdERAoT15HAn4BhbTy/EBjk7jXA\nucAfY9pv2aqrq0s6hNRQLiLKRUS5iIcVOp60akNmvYE73X2XNaxXBTzj7r1aec7jikdEpFKYGZ6h\nxvDxwD0J7DdTcrlc0iGkhnIRUS4iykU8SnqKqJntDXwbGLi6derq6qiurgagqqqKmpoaamtrgegf\nXcuVtdwkLfEkudzQ0JCqeJJcbmhoSFU8pVzO5XLU19cDrPq87KySDQeZ2S7ArcBwd39xNetoOEhE\npIPSMhxk+cennzDbmlAARq2uAIiISOnFdYro9cBsYFsze9nMvm1mJ5nZiflVzgQ2Bi4zsyfNbE4c\n+y1nLYdCKplyEVEuIspFPGLpCbj7UWt4/gTghDj2JSIi8YmtJxAH9QRERDouLT0BERHJGBWBlNJ4\nZ0S5iCgXEeUiHioCIiIVTD0B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xG97fnb/7al5MNB7r7SzE4GphGK\n0JXuPs/MxgOPuvtdwJXAtWb2AvAm4R++7LQzFxcBnwFuzg+JvOTuhyQXdXG0Mxef+BPKdDioPblw\n96lmtp+ZzQVWAKeV49FyO18XpwF/NLMfEZrEx65+i9llZtcDtcDnzOxlYBywDuDufrm7321mB5jZ\nP4H3gG+3a7v504lERKQC6YphEZEKpiIgIlLBVARERCqYioCISAVTERARqWAqAiIiFUxFQESkgqkI\niIhUsP8H95VsZUlH2V4AAAAASUVORK5CYII=\n",
            "text/plain": [
              "<matplotlib.figure.Figure at 0x7ff76cdad748>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "dt = dx # experiment with this\n",
        "\n",
        "#current_f = f_advection\n",
        "#current_f = f_heat\n",
        "current_f = f_wave\n",
        "\n",
        "for i in range(5): # takes this many time steps at a time\n",
        "    current_u = rk4_step(current_u, current_t, dt, current_f)\n",
        "    current_t += dt\n",
        "\n",
        "pt.ylim([-0.25, 1.25])\n",
        "pt.grid()\n",
        "pt.plot(mesh, current_u[0])"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": true
      },
      "outputs": [],
      "source": []
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.5.1+"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}